package org.video.demo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.TypeReference;
import org.springframework.web.bind.annotation.*;
import org.video.cj.info.dsjlistinfo;
import org.video.cj.info.dyListinfo;
import org.video.cj.info.indexinfo;
import org.video.cj.lmp.cjinfolmp;

import java.util.Collections;
import java.util.List;

@RestController
public class hi {


        @RequestMapping("/hello")
        public String hello() {


            cjinfolmp s=new cjinfolmp();

			String jsonString = "";
            List<indexinfo> s1=s.index("https://www.360kan.com/dianying/list");
            JSON json=new JSONArray(Collections.singletonList(s1));
		    return json.toString();
        }
    @RequestMapping("/hellos")
    public String hellos() {
        cjinfolmp s=new cjinfolmp();
        String jsonString = "";
        List<indexinfo> s2= s.index("https://www.360kan.com/dianshi/list");
        JSON json=new JSONArray(Collections.singletonList(s2));
        return json.toString();
    }
    @RequestMapping("/fenlei")
    @ResponseBody
    public String fenlei(@RequestParam("pageno") String pageno,@RequestParam("dy") String dy, @RequestParam("dsj") String dsj,@RequestParam("dm") String dm) {
        System.out.println(dsj);
        cjinfolmp s=new cjinfolmp();
            if(Integer.parseInt(pageno)>0){
                if (!dsj.equals("-1")&!dsj.equals("0")) {
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianshi/list?cat=" + dsj+"&pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                } else if (!dy.equals("-1")&!dy.equals("0")) {
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianying/list?cat=" + dy+"&pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                } else if (!dm.equals("-1")&!dm.equals("0")) {
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dongman/list?cat=" + dm+"&pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                } else if(dsj.equals("0")){
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianshi/list?pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                }else if(dy.equals("0")){
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianying/list?pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                }else if(dm.equals("0")){
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dongman/list?pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                }
            }else {
                if (!dsj.equals("-1")&!dsj.equals("0")) {
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianshi/list?cat=" + dsj+"pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                } else if (!dy.equals("-1")&!dy.equals("0")) {
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianying/list?cat=" + dy+"pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                } else if (!dm.equals("-1")&!dm.equals("0")) {
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dongman/list?cat=" + dm+"pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                } else if(dsj.equals("0")){
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianshi/list?pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                }else if(dy.equals("0")){
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dianying/list?pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                }else if(dm.equals("0")){
                    List<indexinfo> s2 = s.index("https://www.360kan.com/dongman/list?pageno="+pageno);
                    JSON json = new JSONArray(Collections.singletonList(s2));
                    return json.toString();
                }
            }
            return "";
    }

        @RequestMapping("/playdy")
        @ResponseBody
        public String play(@RequestParam("dy") String a){
            cjinfolmp s=new cjinfolmp();
            System.out.println(a);
            List<dyListinfo> s1=s.dy(a);
            for (dyListinfo d:s1) {
                System.out.println(d.getName());
            }
            JSON json=new JSONArray(Collections.singletonList(s1));


            return json.toString();
        }
    @RequestMapping("/playdsj")
    @ResponseBody
    public String playdsj(@RequestParam("dsj") String a){
        cjinfolmp s=new cjinfolmp();
        System.out.println(a);
        List<dsjlistinfo> s1=s.dsj(a);
        for (dsjlistinfo d:s1) {
            System.out.println(d.getName());
        }
        JSON json=new JSONArray(Collections.singletonList(s1));
        return json.toString();
    }
    @RequestMapping("/playdm")
    @ResponseBody
    public String playdm(@RequestParam("dm") String a){
        cjinfolmp s=new cjinfolmp();
        System.out.println(a);
        List<dsjlistinfo> s1=s.dm(a);
        for (dsjlistinfo d:s1) {
            System.out.println(d.getName());
        }
        JSON json=new JSONArray(Collections.singletonList(s1));
        return json.toString();
    }
    @RequestMapping("/sou")
    @ResponseBody
    public String sou(@RequestParam("text") String a){
        cjinfolmp s=new cjinfolmp();
        System.out.println(a);
        String h="https://so.360kan.com/index.php?kw="+a;
        List<indexinfo> s1=s.sou(h);
        JSON json=new JSONArray(Collections.singletonList(s1));
        return json.toString();
    }

}
